package com.etc.dao.impl;

import com.etc.dao.GoodsDao;
import com.etc.entity.Goods;
import com.etc.util.DBUtil;
import com.etc.util.PageData;
import org.springframework.stereotype.Repository;

/**
 * 商品的dao实现类
 */
@Repository
public class GoodsDaoImpl  implements GoodsDao {

//    @Override
//    public PageData getByPage(int pageNo, int pageSize, String keywords) {
//        String sql = "select * from tbl_goods where goodsname like ? or goodsinfo like ?";
//        return DBUtil.exQueryByPage(sql, Goods.class,pageNo,pageSize,"%"+keywords+"%","%"+keywords+"%");
//    }

    @Override
    public PageData getByPage(int pageNo, int pageSize, String keywords) {
        String sql = "SELECT tbl_goods.goodsid, tbl_goods.goodsname, tbl_goods.goodsprice, tbl_goods.goodsinfo, tbl_goods.goodscount, tbl_goods.cover, tbl_goods.typeid, tbl_goods.shopid, tbl_goods.goodsstate, tbl_shop.shopname, tbl_goodstype.typename, tbl_goodstype.typeinfo FROM tbl_goods INNER JOIN tbl_shop ON tbl_goods.shopid = tbl_shop.shopid INNER JOIN tbl_goodstype ON tbl_goods.typeid = tbl_goodstype.typeid where tbl_goods.goodsname like ? or tbl_goods.goodsinfo like ?";
        return DBUtil.exQueryByPage(sql, Goods.class,pageNo,pageSize,"%"+keywords+"%","%"+keywords+"%");
    }

}
